Title: SQL W3S (By-BKK) / 023 Between
Tags: Obsidian_to_Anki

Q: What does the SQL BETWEEN operator do?
A: It selects values within a specified range (inclusive)

Q: Is the SQL BETWEEN operator inclusive or exclusive?
A: Inclusive; both start and end values are included

Q: What SQL clause would you use to get all products priced between 10 and 20?
A: WHERE Price BETWEEN 10 AND 20

Q: True/False: BETWEEN can be used with numbers, text, or dates
A: True

Q: Which is syntactically correct for using BETWEEN in SQL?
A: SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2

Q: How would you reverse the range selection using SQL?
A: Use NOT BETWEEN to exclude values in the range

Q: Give an example SQL query that finds products NOT priced between 10 and 20
A: SELECT * FROM Products WHERE Price NOT BETWEEN 10 AND 20

Q: Can BETWEEN be used with the IN operator?
A: Yes, for example when combining ranges with specific sets

Q: How do you select products with Price between 10 and 20 and CategoryID of 1, 2, or 3?
A: SELECT * FROM Products WHERE Price BETWEEN 10 AND 20 AND CategoryID IN (1, 2, 3)

Q: True/False: BETWEEN can be used to filter alphabetic/text ranges
A: True

Q: How do you select product names alphabetically between ‘A’ and ‘M’ (example)?
A: WHERE ProductName BETWEEN 'A' AND 'M'

Q: What does NOT BETWEEN do with text values?
A: It excludes values between the two text values

Q: How do you select orders with OrderDate between two dates?
A: WHERE OrderDate BETWEEN ‘start_date’ AND ‘end_date’

Q: Give a SQL example to select orders between July 1 and July 31, 1996
A: SELECT * FROM Orders WHERE OrderDate BETWEEN '1996-07-01' AND '1996-07-31'

Q: BETWEEN includes boundary values. True or False?
A: True

Q: Inclusive means?
A: Both endpoints in the range are included

Q: BETWEEN operator lets you select values inside or outside a range?
A: Inside (use NOT BETWEEN for outside)

Q: Reverse: Values within a given range can be selected with which operator?
A: BETWEEN

Q: Reverse: What does NOT BETWEEN do?
A: Excludes values in the specified range

Q: Reverse: True/False - The BETWEEN operator supports dates as range limits
A: True

Q: Reverse: SELECT * FROM Products WHERE Price BETWEEN 10 AND 20. What does this query return?
A: All products with a price from 10 to 20, including 10 and 20